package cz.vargagab.view;

import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.view.document.AbstractPdfView;

import com.lowagie.text.Document;
import com.lowagie.text.Table;
import com.lowagie.text.pdf.PdfWriter;

import cz.vargagab.domain.LogObject;

public class PdfView extends AbstractPdfView {

	@Override
	protected void buildPdfDocument(Map model, Document document, PdfWriter writer, HttpServletRequest request, HttpServletResponse response) throws Exception {

		List<LogObject> logs = (List<LogObject>) model.get("logs");

		Table table = new Table(2);
		table.addCell("Datum");
		table.addCell("Udalost");
		for (LogObject log : logs) {
			table.addCell(log.getTime().toString());
			table.addCell(log.getText());
		}

		document.add(table);
	}

}